/**
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.representation.ActionBaseClass;
import edu.wpi.cs509.representation.GameID;


/**
 * This class implements the client to server messages for moving a
 * game piece. 
 * @author sparadis
 *
 */
public class MsgMovePiece extends MsgServerContext {
	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * gId: id of game for piece to be moved
	 * move: the move
	 */
	protected GameID          gId;
	protected ActionBaseClass move; 
	
	/**
	 * Constructor
	 * @param gId - id of game to observe.
	 * @param move - the requested move
	 */
	public MsgMovePiece(GameID gId, ActionBaseClass move) {
		this.gId = gId;
		this.move = move;
	}

	/**
	 * Move the piece.
	 * @return MsgBc - null in this case, as the server will send all 
	 * reply messages.
	 */
	@Override
	public MsgBc doExecuteAndGetReply() {
		
		System.out.println("in MsgMovePiece.doExecuteAndGetReply() ...");
		
		//Call the server to move the piece.
		getServer().movePiece(gId, move, getConnection());
		
		//The server's movePiece function owns sending all replies.
		//Thus, return null here to stop the auto-reply code. 
		return null;
	}
}
